package com.shop2cn.iapi.member.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.member.parameter.CreateMemberBean;
import com.shop2cn.iapi.member.parameter.ReceiveDeleteCsBean;
import com.shop2cn.iapi.member.service.ReceiveDeleteCsCall;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.GodMemberService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godmember.Member;
import com.ymttest.database.sqlwapper.godmember.GodMemberWapper;
import com.ymttest.utils.TestDataManager;
/**
*根据手机号查询电铺会员
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ReceiveDeleteCs{
	private static ReceiveDeleteCsBean ReceiveDeleteCsBean;
	private static ReceiveDeleteCsCall ReceiveDeleteCsCall;
	private static Integer shopid ;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("删除客服用户");
		try {
			shopid= GodmchManageCallService.CreateSellerMch();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		ReceiveDeleteCsBean=new ReceiveDeleteCsBean();
		ReceiveDeleteCsCall=new ReceiveDeleteCsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(ReceiveDeleteCsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReceiveDeleteCs_001() {
		Logger.start(true,"删除客服用户成功");
		try {
			//创建一个新会员
			UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(usercreateBean);
			UserCreateBean u = DGUserCallService.initCsUsercreateBean();
			Integer csId = DGUserCallService.UserCreateCall(u);
			CreateMemberBean createMem = GodMemberService.initCreateMemberBean(shopid,userId,usercreateBean.getOpenId());
			createMem.setOpenId(usercreateBean.getOpenId());
			String memid = GodMemberService.creatememberCall(createMem);
			String mobile=TestDataManager.getPhoneNum();
			GodMemberService.bindMobile(shopid, userId, mobile,csId);
			ReceiveDeleteCsBean.setUserId(csId);
			ReceiveDeleteCsCall.setData(ReceiveDeleteCsBean);
			ReceiveDeleteCsCall.callService();			
			Logger.verifyEquals("ok", ReceiveDeleteCsCall.getReturnData(), "验证返回");
			GodMemberWapper GodMemberWapper=new GodMemberWapper();
			Member mem = GodMemberWapper.selectMemberByMemberid(memid).get(0);
			Logger.debug(FormatUtil.beanToGSONString(mem));
			Logger.verifyEquals(0,mem.getCsId(), "删除用户csid");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}